home *** CD-ROM | disk | FTP | other *** search
- Q33369 Loop Optimizations Problems with Unsigned Chars
- C Compiler
- 5.10 | 5.10
- MS-DOS | OS/2
-
- Summary:
- When a program is compiled with loop optimization in C Version
- 5.10, the use of unsigned chars in for loops may cause optimization
- problems under certain circumstances.
- You can avoid these problems by either rearranging your code or
- using unsigned short instead of unsigned char or by compiling without
- loop optimization.
- Microsoft has confirmed this to be a problem in Version 5.10. We
- are researching this problem and will post new information as it
- becomes available.
-
- More Information:
- The following is a sample program:
-
- #include <stdio.h>
-
- void main()
- {
- unsigned char aa,bb;
- unsigned char array[2][5];
- unsigned char *name = "STUFF";
-
- for (aa=0;aa<2;aa++) {
- name = "STUFF";
- for (bb=0;bb<5;bb++) {
- array[aa][bb] = *name;
- name++;
- }
- }
-
- for (aa=0;aa<2;aa++) {
- for (bb=0;bb<5;bb++) {
- putchar(array[aa][bb]);
- }
- putchar('\n');
- }
- }
-
- >From the mixed code listing, there seems to be a problem with a
- temporary variable being initialized as a BYTE and accessed as a WORD.
- In the following fragment, PTR [bp-18] is variable in question.
-
- ;|*** for (aa=0;aa<2;aa++) {
- ; Line 10
- *** 00000b c6 46 fc 02 mov BYTE PTR [bp-4],2 ;aa
- *** 00000f c7 46 fe 0b 00 mov WORD PTR [bp-2],OFFSET DGROUP:$SG166+5 ;name
- *** 000014 c6 46 ee 00 mov BYTE PTR [bp-18],0
- $L20002:
- ;|*** name = "STUFF";
- ;|*** for (bb=0;bb<5;bb++) {
- ; Line 12
- *** 000018 c6 46 fa 00 mov BYTE PTR [bp-6],0 ;bb
- *** 00001c 8b 76 ee mov si,WORD PTR [bp-18]
-
-
- Keywords: buglist5.10
- Updated 88/08/03 09:57
-